import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main33 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        Map<Character, Integer> map = new HashMap<>();
        while (t-- != 0) {
            int n = in.nextInt();
            in.nextLine();
            String[] s = new String[n];
            for (int i = 0; i < n; i++) {
                s[i] = in.nextLine();
                for (int j = 0; j < s[i].length(); j++) {
                    char ch = s[i].charAt(j);
                    map.put(ch, i);
                }
            }
            boolean flag = true;
            for (int i = 0; i < n / 2; i++) {
                int j = n - i - 1;
                for(int m = 0; m < s[i].length(); m++) {
                    char ch = s[i].charAt(m);
                    Set<Map.Entry<Character, Integer>> set = map.entrySet();
                    Map.Entry<Character, Integer> tmp = new AbstractMap.SimpleEntry<>(ch, j);
                    if (!set.contains(tmp)) {
                        flag = false;
                        break;
                    }
                }
                if(!flag) {
                    System.out.println("No");
                    break;
                }
            }
            if (flag) {
                System.out.println("Yes");
            }
        }
    }
}